import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_syt/domain/widgets/flow_item.dart';
import 'package:flutter_syt/utils/click_utils.dart';
import 'package:yyy_route_annotation/yyy_route_annotation.dart';

import '../../global_easy_loading.dart';

@RoutePage(name: "testList")
class ListPage extends StatefulWidget {
  @override
  _ListPageState createState() => _ListPageState();
}

class _ListPageState extends State<ListPage>
    with AutomaticKeepAliveClientMixin {
  @override
  void initState() {
    super.initState();
  }

  List<FlowItemEntity> fakeData() {
    return [
      FlowItemEntity.create(
        "残奥赛会各项目竞委会新闻宣传及 媒体运行工作会议在西安召开",
        DateTime.now().millisecondsSinceEpoch,
        "https://avatars2.githubusercontent.com/u/20411648?s=460&v=4",
        "",
      ),
      FlowItemEntity.create(
        "残奥赛会各项目竞委会新闻宣传及 媒体运行工作会议在西安召开",
        DateTime.now().millisecondsSinceEpoch,
        "https://avatars2.githubusercontent.com/u/20411648?s=460&v=4",
        "",
      ),
      FlowItemEntity.create(
        "残奥赛会各项目竞委会新闻宣传及 媒体运行工作会议在西安召开",
        DateTime.now().millisecondsSinceEpoch,
        "https://avatars2.githubusercontent.com/u/20411648?s=460&v=4",
        "",
      ),
      FlowItemEntity.create(
        "残奥赛会各项目竞委会新闻宣传及 媒体运行工作会议在西安召开",
        DateTime.now().millisecondsSinceEpoch,
        "https://avatars2.githubusercontent.com/u/20411648?s=460&v=4",
        "",
      ),
    ];
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: ListView(
          padding: EdgeInsets.all(10),
          children: fakeData()
              .map((e) => GestureDetector(
                    onTap: ClickUtils.debounce(() {
                      customShowToast("HHH");
                    }),
                    child: FlowItem(e),
                  ))
              .toList(),
        ),
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
